<div class="page-header">
    <h1><?php echo $this->titulo; ?></h1>
</div>

<form class="form-inline" role="form">
    <div class="form-group">
        <div class="input-group">
            <label class="sr-only" for="dscfiltro">Produto</label>
            <input type="text" class="form-control" id="dscfiltro" name="dscfiltro" placeholder="Produto" value="<?php echo $this->dscfiltro; ?>">
        </div>
    </div>
    <div class="form-group">
        <button type="submit" class="btn btn-default">
            <span class="glyphicon glyphicon-search" aria-hidden="true"></span>
            Pesquisar
        </button>
    </div>    
</form>

<div class="table-responsive">
    <table id="tlist" class="table table-striped table-hover">
        <thead>
            <tr>
                <th>Código</th>
                <th>Produto</th>
                <th>Qtd Disponível</th>
                <th>Qtd Min</th>
                <th>Qtd Max</th>
                <th class="bc">&nbsp;</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($this->result as $row) { 
                $query = 'SELECT SQL_CACHE sum(E.ESL_QTD) as ESL_QTD FROM ESTOQUE B, ESTOQUE_LANCAMENTO E'
                .' WHERE B.PRO_ID = '.$row['PRO_ID']
                .' AND B.EST_ID = E.EST_ID AND B.EST_STA = 1 AND E.ESL_STA = 1';
                $est = $this->db->fetchRow($query);
            ?>
                <tr>
                    <td><?php echo $row['PRO_ID']; ?></td>
                    <td><?php echo $row['PRO_NOM']; ?></td>
                    <td><?php echo $est['ESL_QTD']; ?></td>
                    <td><?php echo $row['EST_QTDMIN']; ?></td>
                    <td><?php echo $row['EST_QTDMAX']; ?></td>
                    <td class="bc">
                        <?php if($this->per_edt){?><a class="btn btn-sm btn-primary" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit', 'id' => $row['EST_ID'])); ?>"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span> Editar</a><?php }?>
                        <?php if($this->per_del && $row['EST_STA'] == 0){?><a class="btn btn-sm btn-danger" href="javascript:void(0);" onclick="list_delete_msg('<?php echo $this->controller; ?>', <?php echo $row['EST_ID'] ?>, $(this), '<?php echo $row['EST_NOM'] ?>');"><span class="glyphicon glyphicon-floppy-remove" aria-hidden="true"></span> Deletar</a><?php }?>
                        <?php if($this->per_edt){?><a class="btn btn-sm btn-success" href="<?php echo $this->url(array('controller' => 'estoquelancamento', 'action' => 'index', 'est_id' => $row['EST_ID'])); ?>"><span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span> Lançamento</a><?php }?>
                    </td>
                </tr>
            <?php } ?>
        </tbody>
    </table>
 <?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml'); ?>
</div>